From: Philip Withnall Date: Tue, 8 Aug 2017 14:39:34 +0000 (+0100) Subject: lib/repo: Fix handling of missing summary files when downloading X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~33^2~27 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=1672e2eee058d0fe41ed102ca310a9634d36572f;p=ostree.git lib/repo: Fix handling of missing summary files when downloading The API for downloading a summary file can legitimately return NULL for the summary file contents when it returns TRUE (success). This indicates an error 404 — the summary file was not found. Two call sites were not handling that correctly, which was causing later assertion failures. Signed-off-by: Philip Withnall Closes: #1061 Closes: #1065 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo-finder-avahi.c b/src/libostree/ostree-repo-finder-avahi.c index e9e2471a..a1500567 100644 --- a/src/libostree/ostree-repo-finder-avahi.c +++ b/src/libostree/ostree-repo-finder-avahi.c @@ -556,7 +556,8 @@ get_refs_and_checksums_from_summary (GBytes *summary_bytes, } /* Download the summary file from @remote, and return the bytes of the file in - * @out_summary_bytes. */ + * @out_summary_bytes. This will return %TRUE and set @out_summary_bytes to %NULL + * if the summary file does not exist. */ static gboolean fetch_summary_from_remote (OstreeRepo *repo, OstreeRemote *remote, @@ -648,6 +649,13 @@ get_checksums (OstreeRepoFinderAvahi *finder, error)) return FALSE; + if (summary_bytes == NULL) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, + "No summary file found on server"); + return FALSE; + } + return get_refs_and_checksums_from_summary (summary_bytes, supported_ref_to_checksum, error); } diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 8c0c4ff1..6298a28e 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -4834,6 +4834,14 @@ find_remotes_cb (GObject *obj, g_clear_error (&error); continue; } + else if (summary_bytes == NULL) + { + g_debug ("%s: Failed to download summary for result ‘%s’. Ignoring. %s", + G_STRFUNC, result->remote->name, + "No summary file exists on server"); + g_clear_pointer (&g_ptr_array_index (results, i), (GDestroyNotify) ostree_repo_finder_result_free); + continue; + } /* Check the metadata in the summary file, especially whether it contains * all the @refs we are interested in. */